package com.adou.d8.thread;

import java.util.concurrent.Callable;

/**
 * 继承Callable
 */
public class MyCallable implements Callable<String> {
    private int n;
    public MyCallable(int n){
        this.n = n;
    }
    /**
     * 重写call
     * @return
     * @throws Exception
     */
    @Override
    public String call() throws Exception {
        // 线程任务
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum+=i;
        }

        return "线程求出1-" + n+ "的和：" +sum;
    }
}
